package com.xiaoy.core.database.entity;

import java.util.List;

public class DataTable {
	
	private final String tableSql = "create table tablename(${column})";
	
	private String name="";
	
	private String info="";		//表注释
	
	private List<Column> columns;
	
	private Sequence sequence;

	public DataTable (){}
	
	public DataTable (String name,String info){
		this.name = name;
		this.info = info;
	}
	
	
	public DataTable (String name){
		this.name=name;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Column> getColumns() {
		return columns;
	}

	public void setColumns(List<Column> columns) {
		this.columns = columns;
	}

	public Sequence getSequence() {
		return sequence;
	}

	public void setSequence(Sequence sequence) {
		this.sequence = sequence;
	}
	
	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String toTable () {
		
		StringBuilder sb = new StringBuilder();
		if (this.columns !=null && columns.size()>0) {
			for (Column column:columns) {
				sb.append(column.toString()+",");
			}
		}
		String col = sb.toString();
		System.out.println(col);
		col = col.substring(0,col.length()-1);
		String re = tableSql.replace("tablename", name).replace("${column}", col);
		return re;
	}
	
	public String toSeq () {
		
		return this.sequence.toString();
	}
	
	
	
	
	
	
	
}

